#pragma once

#include "GameCoreScriptBinder.h"
#include "NetManager.h"
#include "Panel.h"
#include "debugassert.h"

_NAMESPACE_BEGIN

class Net_ScriptBinder
{
public:
	SINGLETON_HELPER(Net_ScriptBinder)
	Net_ScriptBinder();
	~Net_ScriptBinder();

public:
	
};

REGISTER_TYPEMETHODS(NetInterface)
{
	r = engine->RegisterObjectMethod(type,"void Disconnect()", asMETHOD(T,Disconnect), asCALL_THISCALL);	 assert( r >= 0 );
	r = engine->RegisterObjectMethod(type,"void SendFlag(int)", asMETHOD(T,SendFlag), asCALL_THISCALL);	 assert( r >= 0 );
}

REGISTER_TYPEMETHODS(NetClient)
{
	BASEMETHODS(type,T,NetInterface)
	r = engine->RegisterObjectMethod(type,"bool  ConnectToServer(const string&in)", asMETHOD(T,ConnectToServer),  asCALL_THISCALL);	 assert( r >= 0 );
}

REGISTER_TYPEMETHODS(NetServer)
{
	BASEMETHODS(type,T,NetInterface)
	r = engine->RegisterObjectMethod(type,"int  GetClientFromList(string&out,uint)", asMETHOD(T,GetClientFromList),  asCALL_THISCALL);	 assert( r >= 0 );
	r = engine->RegisterObjectMethod(type,"uint  PlayerNums()", asMETHOD(T,PlayerNums),  asCALL_THISCALL);	 assert( r >= 0 );
	r = engine->RegisterObjectMethod(type,"void  SendNetIDtoClient()", asMETHOD(T,SendNetIDtoClient),  asCALL_THISCALL);	 assert( r >= 0 );
	r = engine->RegisterObjectMethod(type,"void CreateOtherCars()", asMETHOD(T,CreateOtherCars),  asCALL_THISCALL);	 assert( r >= 0 );
}

REGISTER_TYPEMETHODS(NetManager)
{		
	BASEMETHODS(type,T,Panel)
	r = engine->RegisterObjectProperty(type, "NetInterface@ net",offsetof(T,net)); assert( r >= 0 );	
 	r = engine->RegisterObjectMethod(type,"void Shutdown()", asMETHOD(T,Shutdown), asCALL_THISCALL);	 assert( r >= 0 );
 	r = engine->RegisterObjectMethod(type,"void CreateAsServer()", asMETHOD(T,CreateAsServer), asCALL_THISCALL);	 assert( r >= 0 );
	r = engine->RegisterObjectMethod(type,"void CreateAsClient()", asMETHOD(T,CreateAsClient), asCALL_THISCALL);	 assert( r >= 0 );
 	r = engine->RegisterObjectMethod(type,"uint GetServerCount()", asMETHOD(T,GetServerCount), asCALL_THISCALL);	 assert( r >= 0 );
 	r = engine->RegisterObjectMethod(type,"void  SeekforServer(int)", asMETHOD(T,SeekforServer),  asCALL_THISCALL);	 assert( r >= 0 );
	r = engine->RegisterObjectMethod(type,"bool  IsWaitingRoom()", asMETHOD(T,IsWaitingRoom),  asCALL_THISCALL);	 assert( r >= 0 );
	r = engine->RegisterObjectMethod(type,"uint  GetNetID()", asMETHOD(T,GetNetID),  asCALL_THISCALL);	 assert( r >= 0 );
	r = engine->RegisterObjectMethod(type,"void GetSelfCar(PhysCar@)", asMETHOD(T,GetSelfCar),  asCALL_THISCALL);	 assert( r >= 0 );
	r = engine->RegisterObjectMethod(type,"void  SetWaitingRoomFlag(bool)", asMETHOD(T,SetWaitingRoomFlag),  asCALL_THISCALL);	 assert( r >= 0 );
	r = engine->RegisterObjectMethod
		(type,"void  GetRoomList(uint,RoomDesc&out)", asMETHOD(T,GetRoomList),  asCALL_THISCALL);	 assert( r >= 0 );
}

_NAMESPACE_END